<?php
//No direct access
defined('_JEXEC') or die('Restricted access');
?>
<div id="ownservices">
	<div id="mainownservice">
	<h3><?php echo JText::_('OWNSERVICE_TRANSACTION_DETAIL'); ?></h3>
	<hr />
	<?php
		$priceformat = OwnserviceHelper::getParams('price_format', '#,###.##');
		$dateformat  = OwnserviceHelper::getParams('date_format', '%d/%m/%Y');
		$timeformat	 = OwnserviceHelper::getParams('time_format', '%H:%i:%s');
		$row = $this->row;
		$instance =& JFactory::getDate($row->created); 
		$link_user = JRoute::_('index.php?option=com_ownservice&controller=member&task=detail&id='.$row->p_id);
		$link_account= JRoute::_('index.php?option=com_ownservice&controller=account&task=detail&id='.$row->a_id);
	?>
	<table class="admintable">
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_RECEIVER_NO'); ?></td>
			<td><?php echo $row->transactionid; ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_TRANSFER_ON'); ?></td>
			<td><?php echo JHTML::_('date', $row->created, $dateformat).' '.date($timeformat, $instance->toUnix()); ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_STATUS'); ?></td>
			<td align="left"><?php echo OwnserviceHelper::getStatus($row->id, $row->state); ?></td>
		</tr>
		<?php if( $this->access->canApprovalTransferred && $row->id && ($row->state == 3 || $row->state == 5)): ?>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_STAFF_TRANSFER'); ?></td>
			<td align="left"><?php echo $row->firstname.' '.$row->lastname; ?></td>
		</tr>
		<?php endif; ?>
		<tr>
			<td colspan="2"><hr /></td>
		</tr>
		<tr>
			<td colspan="2"><h3><?php echo JText::_('OWNSERVICE_SENDER'); ?></h3></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_SENDER'); ?></td>
			<td><a href="<?php echo $link_user; ?>"><?php echo $row->name.' ('.$row->username.')'; ?></a></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_ADDRESS'); ?></td>
			<td><?php echo $row->p_address.' '.$row->p_city.' '.$row->p_state.' '.$row->p_postcode.' '.$row->p_country; ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_PHONE'); ?></td>
			<td><?php echo $row->p_phone_no; ?></td>
		</tr>
		<tr>
			<td colspan="2"><hr /></td>
		</tr>
		<tr>
			<td colspan="2"><h3><?php echo JText::_('OWNSERVICE_PAYEE'); ?></h3></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_ACCOUNT_NAME'); ?></td>
			<td><a href="<?php echo $link_account; ?>"><?php echo $row->account_name; ?></a></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_ACCOUNT_NO'); ?></td>
			<td><?php echo OwnserviceHelper::accountFormat($row->account); ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_ACCOUNT_TYPE'); ?></td>
			<td><?php echo $row->account_type; ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_BANK_NAME'); ?></td>
			<td><?php echo $row->bank_name; ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_BRANCH_NAME'); ?></td>
			<td><?php echo $row->branch_name; ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_ADDRESS'); ?></td>
			<td><?php echo $row->a_address.' '.$row->a_city.' '.$row->a_state.' '.$row->a_postcode.' '.$row->a_country; ?></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_PHONE'); ?></td>
			<td><?php echo $row->a_phone_no; ?></td>
		</tr>
		<tr>
			<td colspan="2"><hr /></td>
		</tr>
		<tr>
			<td colspan="2"><h3><?php echo JText::_('OWNSERVICE_TRANSFER'); ?></h3></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_AMOUNT_TRANSFER').'(AUD)'; ?></td>
			<td>
				<div style="width: 150px; text-align:right;">
					<?php echo OwnserviceHelper::moneyFormat($priceformat,$row->amount); ?> AUD
				</div>
			</td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_FEE').'(AUD)'; ?></td>
			<td>
				<?php
					$color = '';
					if($row->extrafee > 0.00 ){
						$color = 'red';
					} else if($row->extrafee < 0.00 ) {
						$color = 'green';
					}
				?>
				<div style="width: 150px; text-align:right;">
					<span class="<?php echo $color; ?>"><?php echo OwnserviceHelper::moneyFormat($priceformat,($row->fee+$row->extrafee)); ?></span> AUD
				</div>
			</td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_EXCHANGE_RATE'); ?></td>
			<td>
			<?php
				$color = '';
				if($row->extrarate > 0.00 ){
					$color = 'red';
				} else if($row->extrarate < 0.00 ) {
					$color = 'green';
				}
			?>
			<div style="width: 150px; text-align:right;">
				<?php if(!$row->iscore): ?>
				<div style="border-bottom: 1px solid;">
					<?php echo OwnserviceHelper::moneyFormat($priceformat,($row->rate_th)); ?> THB
				</div>
				<?php endif; ?>
				<div>
				<span class="<?php echo $color; ?>">
					<?php echo OwnserviceHelper::moneyFormat($priceformat,($row->rate+$row->extrarate)); ?>
				</span> <?php echo $row->rate_code; ?>
				</div>
			</div>
			</td>
		</tr>
		<tr>
			<td class="key"> <?php echo JText::_('OWNSERVICE_BANK_FEE').'('.$row->rate_code.')'; ?></td>
			<td>
				<?php 
					$color = '';
					if($row->extrabfee > 0.00 ){
						$color = 'red';
					} else if($row->extrabfee < 0.00 ) {
						$color = 'green';
					}
				?>
				<div style="width: 150px; text-align:right;">
				<span class="<?php echo $color; ?>"><?php echo OwnserviceHelper::moneyFormat($priceformat,($row->bankfee+$row->extrabfee)); ?></span> <?php echo $row->rate_code; ?>
				</div>
			</td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_TOTAL_EXCHANGE'); ?></td>
			<td>
				<?php
					$color = '';
					$total = 0;
					if($row->extratotal > 0.00 ){
						$color = 'red';
						$total = $row->extratotal;
					} else {
						$total = ($row->amount * ($row->rate+$row->extrarate));
					}
				?>
				<div style="width: 150px; text-align:right;">
				<?php if(!$row->iscore): ?>
				<div style="border-bottom: 1px solid;">
					<?php echo OwnserviceHelper::moneyFormat($priceformat,$row->total_th); ?> THB
				</div>
				<?php endif; ?>
				<div>
				<span class="<?php echo $color; ?>">
					<?php echo OwnserviceHelper::moneyFormat($priceformat,($total - ($row->bankfee+$row->extrabfee))); ?>
				</span> <?php echo $row->rate_code; ?>
				</div>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="2"><hr /></td>
		</tr>
		<tr>
			<td colspan="2"><h3><?php echo JText::_('OWNSERVICE_REASON'); ?></h3></td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_REASON'); ?> </td>
			<td>
				<?php 
					switch($row->reason):
						case "GIFT":
							echo JText::_('OWNSERVICE_GIFT');
						break;
						case "Monthly Expenses":
							echo JText::_('OWNSERVICE_MONTHLY_EXPENSES');
						break;
						case "Electricity Bill":
							echo JText::_('OWNSERVICE_ELECTRICITY_BILL');
						break;
						case "Water bill":
							echo JText::_('OWNSERVICE_WATER_BILL');
						break;
						case "RENT":
							echo JText::_('OWNSERVICE_RENT');
						break;
						case "SHOPPING":
							echo JText::_('OWNSERVICE_SHOPPING');
						break;
						case "Personal Savings":
							echo JText::_('OWNSERVICE_PERSONAL_SAVINGS');
						break;
						case "AIR FARE":
							echo JText::_('OWNSERVICE_AIR_FARE');
						break;
						case "TRAVEL":
							echo JText::_('OWNSERVICE_TRAVEL');
						break;
						case "MEDICAL":
							echo JText::_('OWNSERVICE_MEDICAL');
						break;
						case "EDUCATION":
							echo JText::_('OWNSERVICE_EDUCATION');
						break;
						case "Car Installment":
							echo JText::_('OWNSERVICE_CAR_INSTALLMENT');
						break;
						case "Car Loan Repayment":
							echo JText::_('OWNSERVICE_CAR_LOAN_REPAYMENT');
						break;
						case "House Intallment":
							echo JText::_('OWNSERVICE_HOUSE_INTALLMENT');
						break;
						case "Home Loan Repayment":
							echo JText::_('OWNSERVICE_HOME_LOAN_REPAYMENT');
						break;
						default:
							echo $row->note;
						break;
					endswitch;
					?>
			</td>
		</tr>
		<tr>
			<td class="key"><?php echo JText::_('OWNSERVICE_COMMENT'); ?></td>
			<td><?php echo $row->comment; ?></td>
		</tr>
		</table>
	</div>
</div>
<script language="javascript" type="text/javascript">
	<!--
	window.print();
	//-->
</script>
